/*
 * *
 * author:cgm
 * date:18-5-21 下午6:26
 * /
 */

package com.kaili.common.exports;

import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
import com.kaili.common.exports.base.BaseExport;
import com.kaili.common.exports.base.ExportNotice;
import com.kaili.db.service.IHsOptRewbService;
import com.kaili.pojo.vo.RewbBaseVo;
import com.kaili.pojo.vo.RewbCheckVo;
import com.kaili.pojo.vo.RewbQueryVo;
import com.kaili.common.exception.BaseExcept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.kaili.except.ResponseStatus.REWB_EXPORT_ERR;

/**
 * package name:com.kaili.common.exports
 * author:hasee
 * date :2018/5/21
 * project:micro-service
 */
@Component
@ExportNotice(name = "签回单导出")
public class ExportRewbQueryList extends BaseExport {
    @Autowired
    IHsOptRewbService rewbService;

    @Override
    public HashMap doExport(Map parm) {
        if (parm.get("type") == null) {
            throw new BaseExcept(REWB_EXPORT_ERR);
        }
        HashMap ret = new HashMap();
        List<RewbQueryVo> list;
        switch ((Integer) parm.get("type")) {
            case 1:
            case 2:
                ret.put(NormalExcelConstants.CLASS, RewbBaseVo.class);
                break;
            case 3:
            case 4:
                ret.put(NormalExcelConstants.CLASS, RewbCheckVo.class);
                break;
            case 5:
            case 6:
                ret.put(NormalExcelConstants.CLASS, RewbQueryVo.class);
                break;
        }
        list = rewbService.getRewbList(parm);
        ret.put(NormalExcelConstants.DATA_LIST, list);
        return ret;
    }
}
